<!-- Home -->
<template>
  <div>
    <van-nav-bar fixed>
      <template #left>
        <img class="logo" :src="imgObj"/>
      </template>
      <template #right>
        <van-icon name="search" size="18" color="#fff" />
      </template>
    </van-nav-bar>
    <!-- 频道部分 -->
    <van-tabs v-model="channelId" offset-top="1.226667rem" animated sticky>
          <van-tab v-for="item in channelList" :title="item.name" :key="item.id" :name="item.id">
    <article-list :cid='channelId' ></article-list>
  </van-tab>
    </van-tabs>
  </div>
</template>

<script>
import logoPng from '../../assets/toutiao_logo.png'
import { userChannelAPI } from '@/api'
import ArticleList from '@/views/Home/ArticleList'
export default {
  data () {
    return {
      imgObj: logoPng,
      channelId: 0,
      channelList: [] // 频道数据
    }
  },
  components: {
    ArticleList
  },
  async created () {
    const res = await userChannelAPI()
    this.channelList = res.data.data.channels
  }

}

</script>
<style lang='less' scoped>
.logo {
    width: 100px;
    height: 30px;
}
/* tab内容距离tab导航的距离 */
/deep/ .van-tabs__content{
    padding-top: 22px;
}
</style>
